<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="${aier_keyworks}" name="keywords">
<meta content="${aier_description}" name="description">
<title>${aier_title}</title>
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}social/user/userreg/userreg.css">
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css">

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/arrayList.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>

<script type="text/javascript" src="${aier_js_url}lib/afu.js"></script>
<script type="text/javascript" src="${aier_js_url}jt/td.js"></script>
</head>
<!-- 注册页面 -->
<body class="page-reg">

	<div class="hgroup">
		<h1>
			<i class="icon icon-bluepoint"></i>
			注册爱儿360
		</h1>
	</div>

	<div class="regbox">
		<div class="ornament ornament-left"></div>
		<div class="ornament ornament-right" title="欢迎来到爱儿360！"></div>
		<div class="ornament ornament-splitline"></div>

			<div class="form-section">
				<div class="line clearfix">
					<div class="input-name">
						<i class="icon icon-phone"></i>
						手机号码：
					</div>
					<div class="input-area input-large clearfix">
						<input type="text" name="phoneNumber" id="phoneNumber">
					</div>
					<div class="tip" id="phoneTip"></div>	
				</div>

				<div class="line clearfix">
					<div class="input-name">设置密码：</div>
					<div class="input-area input-large clearfix">
						<input type="password" name="password" id="password">
					</div>
					<div class="tip" id="passwordTip"></div>	
				</div>

				<div class="line clearfix">
					<div class="input-name">确认密码：</div>
					<div class="input-area input-large clearfix">
						<input type="password" name="confirmPwd" id="confirmPwd">
					</div>
					<div class="tip" id="confirmPwdTip"></div>
				</div>

				<div class="line clearfix">
					<div class="input-name">昵称：</div>
					<div class="input-area input-large">
						<input type="text" name="nickname" id="nickname">
					</div>
					<div class="tip" id="nicknameTip"></div>
				</div>
				<div class="line clearfix">
					<div class="input-name">激活码：</div>
					<div class="input-area get-vcode">
						<a class="btn-getcode" href="javascript:void(0);" id="getVcode">
							<span>免费获取短信激活码</span>
						</a>
					</div>
					<div class="input-area input-small confirm-vcode">
						<input type="text" name="vcode" id="vcode">
					</div>
					<div class="tip" id="codeTip"></div>
				</div>
				<div class="btnbar">
					<div class="reg">
						<a class="btn-reg" href="javascript:void(0);" id="regNow">
							<span>立即注册</span>
						</a>
					</div>
				</div>


				<div class="other">
					<div class="message">
						注册即意味着您了解并接受<a href="#">《服务条款》</a>
					</div>

				</div>

			</div><!-- 左边结束 -->
			



				
			<div class="link-login">
				已有账号，<a href="${aier_url}user/userlogindex.shtml">直接登录 &gt;&gt; </a>
			</div>				



	</div>

	<div class="footer">
		<div class="footer-nav">
			<span><a href="#">关于我们</a></span>
			<span>|</span>
			<span><a href="#">英才加盟</a></span>
			<span>|</span>
			<span><a href="#">合作伙伴</a></span>
			<span>|</span>
			<span><a href="#">联系我们</a></span>
			<span>|</span>
			<span><a href="#">法律声明</a></span>
		</div>
		<div class="footer-copyright">
			<span>
				©&nbsp;2013&nbsp;致行物联网版权所有&nbsp;苏ICP备：13007215号-2
			</span>
		</div>
	</div>

<!-- script -->

	<script>
$('#phoneNumber').focus();

$('#phoneNumber').live('input',function(){
	check_phoneNumber();
});

$('#phoneNumber').blur(check_phoneNumber);

$('#password').blur(function(){
	check_password();
});

$('#confirmPwd').blur(function(){
	check_confirmPwd();
});

$('#nickname').blur(function(){
	check_nickname();
});

$('#vcode').blur(function(){
	check_vcode();
});

// 获取激活码
$('#getVcode').click(function() {
	check_phoneNumber();
	if(flag_phoneNumber){
		if (!$(this).hasClass('btn-getcode-disabled')) {
			$('#getVcode').addClass('btn-getcode-disabled');
			$('#getVcode>span').html('<em>60</em>秒后再次获取');

			var rTime = 60;
			function countdown() {
				rTime -= 1;
				// console.log(rTime);
				if ( rTime < 1 ) {
					clearInterval(cs);
					$('#getVcode').removeClass('btn-getcode-disabled');
					$('#getVcode>span').html('免费获取短信激活码');
				} else {
					$('#getVcode>span>em').html(rTime);
				}
			};
			var cs = setInterval(countdown,1000);
			
			var fun = function(data) {};
			exeAjax(ajaxUrl("${aier_url}${aier_urijs}userregindex_showPhoneMessage${aier_suffix}"), fun, 
				{"account" :$("#phoneNumber").val()});	
		}
	} else{
		$().message("请先输入正确的手机号!");
	}
	
});

//检查手机号
var flag_phoneNumber = false;
function check_phoneNumber(){
	var regu = /^[1]([3-8][0-9]{1}|59|58|88|89)[0-9]{8}$/;
	var phoneNumber = $("#phoneNumber").val();
	if(phoneNumber.trim()==""){
		$('#phoneTip').html('<em class="wrong"></em><strong>请输入手机号</strong>');
	}else if(!regu.test(phoneNumber)){
		$('#phoneTip').html('<em class="wrong"></em><strong>手机号格式错误</strong>');
	}else{
		var fun = function(data) {
			if(1==data.s){
				$('#phoneTip').html('<em class="right"></em>');
				flag_phoneNumber = true;
			}else{
				$('#phoneTip').html("<em class='wrong'></em><strong>"+data.error_info+"</strong>");
			}
		};
		exeAjax(ajaxUrl("${aier_url}${aier_urijs}userregindex_checkPhone${aier_suffix}"), fun, 
			{"account" :phoneNumber});		
	} 
}

//检查密码
var flag_password = false;
function check_password(){
	var password = $("#password").val();
	if(password.trim()==""){
		$('#passwordTip').html('<em class="wrong"></em><strong>请输入密码</strong>');
	}else{
		$('#passwordTip').html('<em class="right"></em>');
		flag_password = true;
	}
}

var flag_confirmPwd = false;
function check_confirmPwd(){
	var confirmPwd = $('#confirmPwd').val();
	var password = $("#password").val();

	if (flag_password === true) {
		if ( confirmPwd === password ) {
			$('#confirmPwdTip').html('<em class="right"></em>');
			flag_confirmPwd = true;
		} else {
			$('#confirmPwdTip').html('<em class="wrong"></em><strong>两次输入的密码不同！</strong>');
		}
	}
}



//检查昵称
var flag_nickname = false;
function check_nickname(){
	var nickname = $("#nickname").val();
	var nickRegExp = /[\u4e00-\u9fa5\_\-a-zA-Z0-9]{2,24}/g;
	if(nickname.trim()==""){
		$('#nicknameTip').html('<em class="wrong"></em><strong>请输入昵称</strong>');
	}else if(!nickRegExp.test(nickname)){
		$('#nicknameTip').html('<em class="wrong"></em><strong>昵称格式错误</strong>');
	} else{
		var fun = function(data) {
			if(1==data.s){
				$('#nicknameTip').html('<em class="right"></em>');
				flag_nickname = true;
			}else{
				$('#nicknameTip').html("<em class='wrong'></em><strong>"+data.error_info+"</strong>");
			}
		};
		exeAjax(ajaxUrl("${aier_url}${aier_urijs}userregindex_checkNickName${aier_suffix}"), fun, 
			{"nickname" :nickname});
	}
}

//检查验证码
var flag_vcode = false;
function check_vcode(){
	var vcode = $("#vcode").val();
	if(vcode.trim()==""){
		$('#codeTip').html('<em class="wrong"></em><strong>请输入验证码</strong>');
	}else{
		$('#codeTip').html('<em class="right"></em>');
		flag_vcode = true;
	}
}

//注册
$('#regNow').click(function(){
	var phoneNumber = $("#phoneNumber").val();
	var password = $("#password").val();
	var nickname = $("#nickname").val();
	var vcode = $("#vcode").val();
	if(flag_phoneNumber&&flag_password&&flag_confirmPwd&&flag_nickname&&flag_vcode){
		var fun = function(data) {
			if(1==data.s){
				$().message("注册成功!");
				//转向首页
				location.href = "${aier_url}${aier_uri}userlogindex${aier_suffix}";
			}else{
				$().message("添加失败,请稍后再试!");
			}
		};
		exeAjax(ajaxUrl("${aier_url}${aier_urijs}userregindex_regUser${aier_suffix}"), fun, 
			{"account" : phoneNumber,"pwd" :password,"nickname" :nickname,"message":vcode});
	}else{
		$().message("输入有误!");
	}
});




//



	function check_phone(phone){
		var regu = /^[1]([3-8][0-9]{1}|59|58|88|89)[0-9]{8}$/;
		var isphone = regu.exec(phone);
		if(isphone!=null){
			return "true";
		}else{
			return "fasle";					
		}			
	}

	</script>

</body>
</html>